#pragma once

#include <common/BlockingQueue.h>
#include <common/EventBase.h>
#include <common/Network.h>
#include <common/Pipeline.h>
#include <common/Rule.h>
#include <folly/MPMCPipeline.h>

namespace flashpp {

class ModelUpdater : public EventBase {
 public:
  ModelUpdater(Pipeline& pipeline, Network& network);

  void process(AtomicOverwrite& ao);

 private:
  void appendPredicate(std::set<HeaderSpace>& aps, HeaderSpace pred);
  // void computeAPs(std::set<HeaderSpace>& hsset, std::set<HeaderSpace>& apset);
  void findCover(HeaderSpace& hs, std::set<HeaderSpace>& apset, std::set<HeaderSpace>& cover);
  Network& network_;
  std::set<HeaderSpace> aps_;
};

} // namespace flashpp